import { createRouter, createWebHashHistory } from "vue-router";
// import SouSuoF from '../views/GoodsList/SouSuoF.vue'
//默认路由
const routes = [
    {
        path: '/',
        redirect: '/guide' 
    },
    {
        path: '/bottomlist',
        name: 'bottomlist',
        component: () => import("../views/GoodsList/GoodsList.vue"),
        
    },
    {
        path: '/sousuof',
        name: 'sousuof',
        component: () => import("../views/GoodsList/SouSuoF.vue")
        ,hidden:true
    },
    {
        path: "/preload",
        name:'preload',
        component: () => import("../views/preload/preload.vue"),
    },
    {
        path: "/guide",
        name:'guide',
        component: () => import("../views/login/guide.vue"),
    },
    {
        path: "/login",
        name:'login',
        component: () => import("../views/login/loginPage.vue"),
    },
    {
        path: "/resetPassword",
        name:'resetPassword',
        component: () => import("../views/login/resetPassword.vue"),
    },
    {
        path: "/register",
        name:'register',
        component: () => import("../views/login/register.vue"),
    },
    {
        path: "/regVerification",
        name:'regVerification',
        component: () => import("../views/login/regVerification.vue"),
    },
    {
        path: "/search",
        name: 'search',
        component: () => import("../components/home/search.vue"),
    },
    {
        path: '/photo',
        name: 'photo',
        component: () => import("../components/home/photo.vue")
    },
    {
        path: '/talk',
        name: 'talk',
        component: () => import("../components/home/talk.vue")
    },
    {
        path: '/void',
        name: 'void',
        component: () => import("../components/home/void.vue")
    },
    {
        path: '/main',
        name: 'main',
        meta: {
            title: '首页'
        },
        component: () => import("../views/layout/index.vue"),
        children: [
            {
                path: 'find',
                name: 'find',
                component: () => import("../views/find/find.vue"),
            },
            {
                path: "/findTalk",
                name:'findTalk',
                component: () => import("../views/find/findTalk.vue"),
            },
            {
                path: "/findFollow",
                name:'findFollow',
                component: () => import("../views/find/findFollow.vue"),
            },
            {
                path: "/perfume",
                name:'perfume',
                component: () => import("../views/find/perfume.vue"),
            },
            {
                path: "/details",
                name:'details',
                component: () => import("../views/find/details.vue"),
            },
            {
                path: "/starHome",
                name:'starHome',
                component: () => import("../views/find/starHome.vue"),
            },
            // 分割一下
            {
                path: 'home',
                name: 'home',
                component: () => import("../views/home/home.vue")
            },
            {
                path: 'rank',
                name: 'rank',
                component: () => import("../views/rank/rank.vue")
            },
            {
                path: 'my',
                name: 'my',
                component: () => import("../views/my/my.vue")
            }
        ],
    }, 
    {
        path:'/user',
        name:'user',
        component: () => import("../views/user/user.vue")
    },
    // // 产品详情
    // {
    //     path: "/cpxq",
    //     name: 'cpxq',
    //     component: () => import("../views/cpxq/index.vue"),
    //     children: [
    //         {
    //             path: "/chanpinpingjiazuo",
    //             name: 'chanpinpingjiazuo',
    //             component: () => import("../components/cpxq/chanpinpingjiazuo.vue"),
    //         },
    //         {
    //             path: "/chanpinpingjiazhong",
    //             name: 'chanpinpingjiazhong',
    //             component: () => import("../components/cpxq/chanpinpingjiazhong.vue"),
    //         },
    //         {
    //             path: "/xiangguantuijianyou",
    //             name: 'xiangguantuijianyou',
    //             component: () => import("../components/cpxq/xiangguantuijianyou.vue"),
    //         },
    //     ]
    // },
    // {
    //     path: "/dianping",
    //     name: 'dianping',
    //     component: () => import("../views/cpxq/dianping.vue")
    // },
    { path: '/:pathMatch(.*)*', name: 'NotFound', component:() => import("../views/404/NotFound.vue") },
];




const router = createRouter({
    history: createWebHashHistory(),
    routes,

});


//   router.beforeEach((to, from, next) => {
//     if (!getLocalToken()) {// 没有登录 
  
//       // 如果没有登录，访问非登录页面,则跳转到登录页面
//       if (to.path != '/login') {
//         next('/login')
//       } else {
//         // 如果没有登录，但访问的是登录页面,直接进入
//         next()
//       }
//     } else {
//       next() // 放行
//     }
  
//   })
  
export default router;

